3.1.17 \(\int (a+b \tan (c+d x))^3 (B \tan (c+d x)+C \tan ^2(c+d x)) \, dx\) [17]

3.1.17.1 Optimal result
3.1.17.2 Mathematica [C] (verified)
3.1.17.3 Rubi [A] (verified)
3.1.17.4 Maple [A] (verified)
3.1.17.5 Fricas [A] (verification not implemented)
3.1.17.6 Sympy [B] (verification not implemented)
3.1.17.7 Maxima [A] (verification not implemented)
3.1.17.8 Giac [B] (verification not implemented)
3.1.17.9 Mupad [B] (verification not implemented)

3.1.17.1 Optimal result

Integrand size = 32, antiderivative size = 165 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=-\left (\left (3 a^2 b B-b^3 B+a^3 C-3 a b^2 C\right ) x\right )-\frac {\left (a^3 B-3 a b^2 B-3 a^2 b C+b^3 C\right ) \log (\cos (c+d x))}{d}+\frac {b \left (a^2 B-b^2 B-2 a b C\right ) \tan (c+d x)}{d}+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d} \]

output
-(3*B*a^2*b-B*b^3+C*a^3-3*C*a*b^2)*x-(B*a^3-3*B*a*b^2-3*C*a^2*b+C*b^3)*ln( 
cos(d*x+c))/d+b*(B*a^2-B*b^2-2*C*a*b)*tan(d*x+c)/d+1/2*(B*a-C*b)*(a+b*tan( 
d*x+c))^2/d+1/3*B*(a+b*tan(d*x+c))^3/d+1/4*C*(a+b*tan(d*x+c))^4/b/d
 
3.1.17.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 1.76 (sec) , antiderivative size = 209, normalized size of antiderivative = 1.27 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {-6 i (a+i b)^4 B \log (i-\tan (c+d x))+6 i (a-i b)^4 B \log (i+\tan (c+d x))-12 b^2 \left (-6 a^2+b^2\right ) B \tan (c+d x)+24 a b^3 B \tan ^2(c+d x)+4 b^4 B \tan ^3(c+d x)+3 C (a+b \tan (c+d x))^4-6 (a B+b C) \left ((i a-b)^3 \log (i-\tan (c+d x))-(i a+b)^3 \log (i+\tan (c+d x))+6 a b^2 \tan (c+d x)+b^3 \tan ^2(c+d x)\right )}{12 b d} \]

input
Integrate[(a + b*Tan[c + d*x])^3*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]
 
output
((-6*I)*(a + I*b)^4*B*Log[I - Tan[c + d*x]] + (6*I)*(a - I*b)^4*B*Log[I + 
Tan[c + d*x]] - 12*b^2*(-6*a^2 + b^2)*B*Tan[c + d*x] + 24*a*b^3*B*Tan[c + 
d*x]^2 + 4*b^4*B*Tan[c + d*x]^3 + 3*C*(a + b*Tan[c + d*x])^4 - 6*(a*B + b* 
C)*((I*a - b)^3*Log[I - Tan[c + d*x]] - (I*a + b)^3*Log[I + Tan[c + d*x]] 
+ 6*a*b^2*Tan[c + d*x] + b^3*Tan[c + d*x]^2))/(12*b*d)
 
3.1.17.3 Rubi [A] (verified)

Time = 0.74 (sec) , antiderivative size = 165, normalized size of antiderivative = 1.00, number of steps used = 10, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.312, Rules used = {3042, 4113, 3042, 4011, 3042, 4011, 3042, 4008, 3042, 3956}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan (c+d x)^2\right )dx\)

\(\Big \downarrow \) 4113

\(\displaystyle \int (a+b \tan (c+d x))^3 (B \tan (c+d x)-C)dx+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (c+d x))^3 (B \tan (c+d x)-C)dx+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 4011

\(\displaystyle \int (a+b \tan (c+d x))^2 (-b B-a C+(a B-b C) \tan (c+d x))dx+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (c+d x))^2 (-b B-a C+(a B-b C) \tan (c+d x))dx+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 4011

\(\displaystyle \int (a+b \tan (c+d x)) \left (-C a^2-2 b B a+b^2 C+\left (B a^2-2 b C a-b^2 B\right ) \tan (c+d x)\right )dx+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (c+d x)) \left (-C a^2-2 b B a+b^2 C+\left (B a^2-2 b C a-b^2 B\right ) \tan (c+d x)\right )dx+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 4008

\(\displaystyle \left (a^3 B-3 a^2 b C-3 a b^2 B+b^3 C\right ) \int \tan (c+d x)dx+\frac {b \left (a^2 B-2 a b C-b^2 B\right ) \tan (c+d x)}{d}-x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \left (a^3 B-3 a^2 b C-3 a b^2 B+b^3 C\right ) \int \tan (c+d x)dx+\frac {b \left (a^2 B-2 a b C-b^2 B\right ) \tan (c+d x)}{d}-x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {b \left (a^2 B-2 a b C-b^2 B\right ) \tan (c+d x)}{d}-\frac {\left (a^3 B-3 a^2 b C-3 a b^2 B+b^3 C\right ) \log (\cos (c+d x))}{d}-x \left (a^3 C+3 a^2 b B-3 a b^2 C-b^3 B\right )+\frac {(a B-b C) (a+b \tan (c+d x))^2}{2 d}+\frac {B (a+b \tan (c+d x))^3}{3 d}+\frac {C (a+b \tan (c+d x))^4}{4 b d}\)

input
Int[(a + b*Tan[c + d*x])^3*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]
 
output
-((3*a^2*b*B - b^3*B + a^3*C - 3*a*b^2*C)*x) - ((a^3*B - 3*a*b^2*B - 3*a^2 
*b*C + b^3*C)*Log[Cos[c + d*x]])/d + (b*(a^2*B - b^2*B - 2*a*b*C)*Tan[c + 
d*x])/d + ((a*B - b*C)*(a + b*Tan[c + d*x])^2)/(2*d) + (B*(a + b*Tan[c + d 
*x])^3)/(3*d) + (C*(a + b*Tan[c + d*x])^4)/(4*b*d)
 

3.1.17.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

rule 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 
3.1.17.4 Maple [A] (verified)

Time = 0.11 (sec) , antiderivative size = 180, normalized size of antiderivative = 1.09

method result size
norman \(\left (-3 B \,a^{2} b +B \,b^{3}-C \,a^{3}+3 C a \,b^{2}\right ) x +\frac {\left (3 B \,a^{2} b -B \,b^{3}+C \,a^{3}-3 C a \,b^{2}\right ) \tan \left (d x +c \right )}{d}+\frac {C \,b^{3} \tan \left (d x +c \right )^{4}}{4 d}+\frac {b \left (3 B a b +3 C \,a^{2}-C \,b^{2}\right ) \tan \left (d x +c \right )^{2}}{2 d}+\frac {b^{2} \left (B b +3 C a \right ) \tan \left (d x +c \right )^{3}}{3 d}+\frac {\left (B \,a^{3}-3 B a \,b^{2}-3 C \,a^{2} b +C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}\) \(180\)
parts \(\frac {\left (B \,b^{3}+3 C a \,b^{2}\right ) \left (\frac {\tan \left (d x +c \right )^{3}}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {\left (3 B a \,b^{2}+3 C \,a^{2} b \right ) \left (\frac {\tan \left (d x +c \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}+\frac {\left (3 B \,a^{2} b +C \,a^{3}\right ) \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {B \,a^{3} \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}+\frac {C \,b^{3} \left (\frac {\tan \left (d x +c \right )^{4}}{4}-\frac {\tan \left (d x +c \right )^{2}}{2}+\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}\) \(183\)
derivativedivides \(\frac {\frac {C \,b^{3} \tan \left (d x +c \right )^{4}}{4}+\frac {B \,b^{3} \tan \left (d x +c \right )^{3}}{3}+C a \,b^{2} \tan \left (d x +c \right )^{3}+\frac {3 B a \,b^{2} \tan \left (d x +c \right )^{2}}{2}+\frac {3 C \,a^{2} b \tan \left (d x +c \right )^{2}}{2}-\frac {C \,b^{3} \tan \left (d x +c \right )^{2}}{2}+3 B \,a^{2} b \tan \left (d x +c \right )-B \,b^{3} \tan \left (d x +c \right )+C \,a^{3} \tan \left (d x +c \right )-3 C a \,b^{2} \tan \left (d x +c \right )+\frac {\left (B \,a^{3}-3 B a \,b^{2}-3 C \,a^{2} b +C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-3 B \,a^{2} b +B \,b^{3}-C \,a^{3}+3 C a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(213\)
default \(\frac {\frac {C \,b^{3} \tan \left (d x +c \right )^{4}}{4}+\frac {B \,b^{3} \tan \left (d x +c \right )^{3}}{3}+C a \,b^{2} \tan \left (d x +c \right )^{3}+\frac {3 B a \,b^{2} \tan \left (d x +c \right )^{2}}{2}+\frac {3 C \,a^{2} b \tan \left (d x +c \right )^{2}}{2}-\frac {C \,b^{3} \tan \left (d x +c \right )^{2}}{2}+3 B \,a^{2} b \tan \left (d x +c \right )-B \,b^{3} \tan \left (d x +c \right )+C \,a^{3} \tan \left (d x +c \right )-3 C a \,b^{2} \tan \left (d x +c \right )+\frac {\left (B \,a^{3}-3 B a \,b^{2}-3 C \,a^{2} b +C \,b^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-3 B \,a^{2} b +B \,b^{3}-C \,a^{3}+3 C a \,b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(213\)
parallelrisch \(\frac {3 C \,b^{3} \tan \left (d x +c \right )^{4}+4 B \,b^{3} \tan \left (d x +c \right )^{3}+12 C a \,b^{2} \tan \left (d x +c \right )^{3}-36 B \,a^{2} b d x +12 B \,b^{3} d x +18 B a \,b^{2} \tan \left (d x +c \right )^{2}-12 C \,a^{3} d x +36 C a \,b^{2} d x +18 C \,a^{2} b \tan \left (d x +c \right )^{2}-6 C \,b^{3} \tan \left (d x +c \right )^{2}+6 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{3}-18 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a \,b^{2}+36 B \,a^{2} b \tan \left (d x +c \right )-12 B \,b^{3} \tan \left (d x +c \right )-18 C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{2} b +6 C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) b^{3}+12 C \,a^{3} \tan \left (d x +c \right )-36 C a \,b^{2} \tan \left (d x +c \right )}{12 d}\) \(248\)
risch \(-3 i B a \,b^{2} x +i B \,a^{3} x +i C \,b^{3} x -\frac {6 i B a \,b^{2} c}{d}-3 B \,a^{2} b x +B \,b^{3} x -C \,a^{3} x +3 C a \,b^{2} x -\frac {6 i C \,a^{2} b c}{d}-3 i C \,a^{2} b x +\frac {2 i \left (9 B \,a^{2} b -12 C a \,b^{2}-4 B \,b^{3}+3 C \,a^{3}-9 i B a \,b^{2} {\mathrm e}^{6 i \left (d x +c \right )}-9 i C \,a^{2} b \,{\mathrm e}^{6 i \left (d x +c \right )}-18 i B a \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-18 i C \,a^{2} b \,{\mathrm e}^{4 i \left (d x +c \right )}-9 i B a \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-9 i C \,a^{2} b \,{\mathrm e}^{2 i \left (d x +c \right )}-12 B \,b^{3} {\mathrm e}^{4 i \left (d x +c \right )}-6 B \,b^{3} {\mathrm e}^{6 i \left (d x +c \right )}+3 C \,a^{3} {\mathrm e}^{6 i \left (d x +c \right )}+9 C \,a^{3} {\mathrm e}^{4 i \left (d x +c \right )}-10 B \,b^{3} {\mathrm e}^{2 i \left (d x +c \right )}+9 C \,a^{3} {\mathrm e}^{2 i \left (d x +c \right )}+6 i C \,b^{3} {\mathrm e}^{4 i \left (d x +c \right )}+6 i C \,b^{3} {\mathrm e}^{2 i \left (d x +c \right )}-18 C a \,b^{2} {\mathrm e}^{6 i \left (d x +c \right )}+27 B \,a^{2} b \,{\mathrm e}^{4 i \left (d x +c \right )}-36 C a \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}+27 B \,a^{2} b \,{\mathrm e}^{2 i \left (d x +c \right )}-30 C a \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+9 B \,a^{2} b \,{\mathrm e}^{6 i \left (d x +c \right )}+6 i C \,b^{3} {\mathrm e}^{6 i \left (d x +c \right )}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {2 i C \,b^{3} c}{d}+\frac {2 i B \,a^{3} c}{d}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B \,a^{3}}{d}+\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B a \,b^{2}}{d}+\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,a^{2} b}{d}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,b^{3}}{d}\) \(579\)

input
int((a+b*tan(d*x+c))^3*(B*tan(d*x+c)+C*tan(d*x+c)^2),x,method=_RETURNVERBO 
SE)
 
output
(-3*B*a^2*b+B*b^3-C*a^3+3*C*a*b^2)*x+(3*B*a^2*b-B*b^3+C*a^3-3*C*a*b^2)/d*t 
an(d*x+c)+1/4*C*b^3/d*tan(d*x+c)^4+1/2*b*(3*B*a*b+3*C*a^2-C*b^2)/d*tan(d*x 
+c)^2+1/3*b^2*(B*b+3*C*a)/d*tan(d*x+c)^3+1/2*(B*a^3-3*B*a*b^2-3*C*a^2*b+C* 
b^3)/d*ln(1+tan(d*x+c)^2)
 
3.1.17.5 Fricas [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 178, normalized size of antiderivative = 1.08 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {3 \, C b^{3} \tan \left (d x + c\right )^{4} + 4 \, {\left (3 \, C a b^{2} + B b^{3}\right )} \tan \left (d x + c\right )^{3} - 12 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} d x + 6 \, {\left (3 \, C a^{2} b + 3 \, B a b^{2} - C b^{3}\right )} \tan \left (d x + c\right )^{2} - 6 \, {\left (B a^{3} - 3 \, C a^{2} b - 3 \, B a b^{2} + C b^{3}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 12 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{12 \, d} \]

input
integrate((a+b*tan(d*x+c))^3*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="f 
ricas")
 
output
1/12*(3*C*b^3*tan(d*x + c)^4 + 4*(3*C*a*b^2 + B*b^3)*tan(d*x + c)^3 - 12*( 
C*a^3 + 3*B*a^2*b - 3*C*a*b^2 - B*b^3)*d*x + 6*(3*C*a^2*b + 3*B*a*b^2 - C* 
b^3)*tan(d*x + c)^2 - 6*(B*a^3 - 3*C*a^2*b - 3*B*a*b^2 + C*b^3)*log(1/(tan 
(d*x + c)^2 + 1)) + 12*(C*a^3 + 3*B*a^2*b - 3*C*a*b^2 - B*b^3)*tan(d*x + c 
))/d
 
3.1.17.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 313 vs. \(2 (151) = 302\).

Time = 0.17 (sec) , antiderivative size = 313, normalized size of antiderivative = 1.90 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\begin {cases} \frac {B a^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 B a^{2} b x + \frac {3 B a^{2} b \tan {\left (c + d x \right )}}{d} - \frac {3 B a b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {3 B a b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} + B b^{3} x + \frac {B b^{3} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac {B b^{3} \tan {\left (c + d x \right )}}{d} - C a^{3} x + \frac {C a^{3} \tan {\left (c + d x \right )}}{d} - \frac {3 C a^{2} b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {3 C a^{2} b \tan ^{2}{\left (c + d x \right )}}{2 d} + 3 C a b^{2} x + \frac {C a b^{2} \tan ^{3}{\left (c + d x \right )}}{d} - \frac {3 C a b^{2} \tan {\left (c + d x \right )}}{d} + \frac {C b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {C b^{3} \tan ^{4}{\left (c + d x \right )}}{4 d} - \frac {C b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{3} \left (B \tan {\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) & \text {otherwise} \end {cases} \]

input
integrate((a+b*tan(d*x+c))**3*(B*tan(d*x+c)+C*tan(d*x+c)**2),x)
 
output
Piecewise((B*a**3*log(tan(c + d*x)**2 + 1)/(2*d) - 3*B*a**2*b*x + 3*B*a**2 
*b*tan(c + d*x)/d - 3*B*a*b**2*log(tan(c + d*x)**2 + 1)/(2*d) + 3*B*a*b**2 
*tan(c + d*x)**2/(2*d) + B*b**3*x + B*b**3*tan(c + d*x)**3/(3*d) - B*b**3* 
tan(c + d*x)/d - C*a**3*x + C*a**3*tan(c + d*x)/d - 3*C*a**2*b*log(tan(c + 
 d*x)**2 + 1)/(2*d) + 3*C*a**2*b*tan(c + d*x)**2/(2*d) + 3*C*a*b**2*x + C* 
a*b**2*tan(c + d*x)**3/d - 3*C*a*b**2*tan(c + d*x)/d + C*b**3*log(tan(c + 
d*x)**2 + 1)/(2*d) + C*b**3*tan(c + d*x)**4/(4*d) - C*b**3*tan(c + d*x)**2 
/(2*d), Ne(d, 0)), (x*(a + b*tan(c))**3*(B*tan(c) + C*tan(c)**2), True))
 
3.1.17.7 Maxima [A] (verification not implemented)

Time = 0.42 (sec) , antiderivative size = 179, normalized size of antiderivative = 1.08 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\frac {3 \, C b^{3} \tan \left (d x + c\right )^{4} + 4 \, {\left (3 \, C a b^{2} + B b^{3}\right )} \tan \left (d x + c\right )^{3} + 6 \, {\left (3 \, C a^{2} b + 3 \, B a b^{2} - C b^{3}\right )} \tan \left (d x + c\right )^{2} - 12 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} {\left (d x + c\right )} + 6 \, {\left (B a^{3} - 3 \, C a^{2} b - 3 \, B a b^{2} + C b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 12 \, {\left (C a^{3} + 3 \, B a^{2} b - 3 \, C a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{12 \, d} \]

input
integrate((a+b*tan(d*x+c))^3*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="m 
axima")
 
output
1/12*(3*C*b^3*tan(d*x + c)^4 + 4*(3*C*a*b^2 + B*b^3)*tan(d*x + c)^3 + 6*(3 
*C*a^2*b + 3*B*a*b^2 - C*b^3)*tan(d*x + c)^2 - 12*(C*a^3 + 3*B*a^2*b - 3*C 
*a*b^2 - B*b^3)*(d*x + c) + 6*(B*a^3 - 3*C*a^2*b - 3*B*a*b^2 + C*b^3)*log( 
tan(d*x + c)^2 + 1) + 12*(C*a^3 + 3*B*a^2*b - 3*C*a*b^2 - B*b^3)*tan(d*x + 
 c))/d
 
3.1.17.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 2670 vs. \(2 (159) = 318\).

Time = 2.37 (sec) , antiderivative size = 2670, normalized size of antiderivative = 16.18 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=\text {Too large to display} \]

input
integrate((a+b*tan(d*x+c))^3*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="g 
iac")
 
output
-1/12*(12*C*a^3*d*x*tan(d*x)^4*tan(c)^4 + 36*B*a^2*b*d*x*tan(d*x)^4*tan(c) 
^4 - 36*C*a*b^2*d*x*tan(d*x)^4*tan(c)^4 - 12*B*b^3*d*x*tan(d*x)^4*tan(c)^4 
 + 6*B*a^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2 
*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^4*tan(c)^4 - 18*C*a^2*b*l 
og(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + 
tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^4*tan(c)^4 - 18*B*a*b^2*log(4*(tan(d* 
x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + 
 tan(c)^2 + 1))*tan(d*x)^4*tan(c)^4 + 6*C*b^3*log(4*(tan(d*x)^2*tan(c)^2 - 
 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1)) 
*tan(d*x)^4*tan(c)^4 - 48*C*a^3*d*x*tan(d*x)^3*tan(c)^3 - 144*B*a^2*b*d*x* 
tan(d*x)^3*tan(c)^3 + 144*C*a*b^2*d*x*tan(d*x)^3*tan(c)^3 + 48*B*b^3*d*x*t 
an(d*x)^3*tan(c)^3 - 18*C*a^2*b*tan(d*x)^4*tan(c)^4 - 18*B*a*b^2*tan(d*x)^ 
4*tan(c)^4 + 9*C*b^3*tan(d*x)^4*tan(c)^4 - 24*B*a^3*log(4*(tan(d*x)^2*tan( 
c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 
 + 1))*tan(d*x)^3*tan(c)^3 + 72*C*a^2*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan 
(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d 
*x)^3*tan(c)^3 + 72*B*a*b^2*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) 
 + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^3*tan(c) 
^3 - 24*C*b^3*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x 
)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^3*tan(c)^3 + 12*C*a...
 
3.1.17.9 Mupad [B] (verification not implemented)

Time = 8.54 (sec) , antiderivative size = 181, normalized size of antiderivative = 1.10 \[ \int (a+b \tan (c+d x))^3 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx=x\,\left (-C\,a^3-3\,B\,a^2\,b+3\,C\,a\,b^2+B\,b^3\right )-\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (\frac {C\,b^3}{2}-\frac {3\,a\,b\,\left (B\,b+C\,a\right )}{2}\right )}{d}-\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (-C\,a^3-3\,B\,a^2\,b+3\,C\,a\,b^2+B\,b^3\right )}{d}+\frac {\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (\frac {B\,a^3}{2}-\frac {3\,C\,a^2\,b}{2}-\frac {3\,B\,a\,b^2}{2}+\frac {C\,b^3}{2}\right )}{d}+\frac {{\mathrm {tan}\left (c+d\,x\right )}^3\,\left (\frac {B\,b^3}{3}+C\,a\,b^2\right )}{d}+\frac {C\,b^3\,{\mathrm {tan}\left (c+d\,x\right )}^4}{4\,d} \]

input
int((B*tan(c + d*x) + C*tan(c + d*x)^2)*(a + b*tan(c + d*x))^3,x)
 
output
x*(B*b^3 - C*a^3 - 3*B*a^2*b + 3*C*a*b^2) - (tan(c + d*x)^2*((C*b^3)/2 - ( 
3*a*b*(B*b + C*a))/2))/d - (tan(c + d*x)*(B*b^3 - C*a^3 - 3*B*a^2*b + 3*C* 
a*b^2))/d + (log(tan(c + d*x)^2 + 1)*((B*a^3)/2 + (C*b^3)/2 - (3*B*a*b^2)/ 
2 - (3*C*a^2*b)/2))/d + (tan(c + d*x)^3*((B*b^3)/3 + C*a*b^2))/d + (C*b^3* 
tan(c + d*x)^4)/(4*d)